competence_code={observation="observation",
    attention="attention",
    memory="memory",
    magination="magination",
    thinking_ability="thinking_ability"}
--observation: 'observation',//观察力
--    attention: 'attention',//注意力
--    memory: 'memory',//记忆力
--    magination: 'magination',//想像力
--    thinking_ability: 'thinking_ability'//思维力
gameSceneInstance=nil
module("gameManger",package.seeall)
---------------------------------------------------------------
require "gameNumberScene"
require "game_1_1_2_Scene"
require "game_1_1_3_Scene"
require "game_1_2_2_Scene"
require "game_1_2_3_Scene"
require "game_1_3_1_Scene"
require "game_1_3_2_Scene"
require "game_1_3_3_Scene"
require "game_1_4_1_Scene"
require "game_1_4_2_Scene"
require "game_1_4_3_Scene"
require "game_1_2_1_1_Scene"
require "game_1_2_1_2_Scene"
require "game_1_2_1_3_Scene"
require "gameNumberScene2"
require "game_2_1_1_2_Scene"
require "game_2_1_1_3_Scene"
require "gameHouseScene"
require "game_family_1_1_Scene"
require "game_3_1_1_1_Scene"
require "game_3_1_1_2_Scene"
require "game_3_1_1_3_Scene"
--require "selectScene2.lua"--qinzi
--ui
--require "choosePetScene"
--require "mainMenuScene"
require "homeScene"
require "boxScene"
require "jz_rukou"
require "jz_main"
require "jz_tx"
require "jz_manage"
require "jz_change"
require "parent&choosepet.jz_mes"
require "parent&choosepet.jz_login"
local _competence_code="observation"
local _challengeTimes={}
local _state=5
vs_user_info=nil--score name pet_id rank
_rank_mes=true
_times=3
function get_cur_data()--获得日期
    return os.date("%m.%d",os.time())
end
local _rank_list={}
function get_cur_rankList()
    local function comp(a,b)
        return a.rank<b.rank
    end
    table.sort(_rank_list,comp)
    return _rank_list
end
local function get_wx_mes(_open_id)--获取用户微信信息（名字，icon）

end
function get_rank_mes(_fun)--获得个人排名信息
    cclog("get_rank_mes-------->")
    require "waitLoad"
    _rank_mes=true
    netWork.get_rank(_competence_code,function(_state,_mes)
        local _table
        if _state==200 then
            _table=json.decode(_mes)
            table_out("_rank_mes",_table)
            local _data=_table.data
            if _data.score==nil then
                cclog("-1-1-1-1-1-1-1--1")
                _table.data={
                    competence_code=_competence_code,
                    score="0",
                    rank="999.."
                }
                _rank_mes=false
            end
            --            _rank_mes=_table.data
        end
        local _str=json.encode(_table)
        cclog("_str----->".._str)
        _fun(_state,_str)
    end)
end
function get_rank_list(_fun)--获取排名列表
    netWork.get_rank_list(_competence_code,function(_state,_mes)
        if _state==200 then
            local _table=json.decode(_mes).data
            _rank_list=_table
        end
        _fun(_state,_mes)
    end
)
end
local _isFirst_come_in=false
local _gameList={
    YX00000111001={score=0,open=false,gname="1-10的读写",zname="描数字",index="1",_fun=crt_NumberScene},
    YX00000111002={score=0,open=false,gname="1-10的数字顺序",zname="收集星星",index="1",_fun=crt_game_1_1_2_Scene},
    YX00000111003={score=0,open=false,gname="1-10的数字观察",zname="找数字",index="1",nkc="KC000000002",_fun=crt_game_1_1_3_Scene},
    YX00000111004={score=0,open=false,gname="数字表示什么？",zname="点泡泡",index="1",_fun=crt_gameHouseScene},
    YX00000111005={score=0,open=false,gname="数一数",zname="包装糖果",index="1",_fun=crt_game_1_2_2_Scene},
    YX00000111006={score=0,open=false,gname="1-5的按数取物",zname="榨果汁",nkc="KC000000003",index="1",_fun=crt_game_1_2_3_Scene},
    YX00000111007={score=0,open=false,gname="6-10的按数取物",zname="钓小鱼",index="1",_fun=crt_game_1_3_1_Scene},
    YX00000111008={score=0,open=false,gname="分类数一数",zname="做蛋糕",index="1",_fun=crt_game_1_3_2_Scene},
    YX00000111009={score=0,open=false,gname="整体认数",zname="数礼物",nkc="KC000000004",index="1",_fun=crt_game_1_3_3_Scene},
    YX00000111010={score=0,open=false,gname="认识多与少",zname="哪边小鱼多?",index="1",_fun=crt_game_1_4_1_Scene},
    YX00000111011={score=0,open=false,gname="一样多",zname="点卡牌",index="1",_fun=crt_game_1_4_2_Scene},
    YX00000111012={score=0,open=false,gname="多几个",zname="小黑猪多几只?",nkc="",index="1",_fun=crt_game_1_4_3_Scene},
    YX00000111013={score=0,open=false,gname="5以内数的分解",zname="运小猪",nkc="",index="1",_fun=crt_game_1_2_1_1_Scene},
    YX00000111014={score=0,open=false,gname="5以内数的组合",zname="装果子",nkc="",index="1",_fun=crt_game_1_2_1_2_Scene},
    YX00000111015={score=0,open=false,gname="5以内的凑数",zname="拼蛋糕",nkc="",index="1",_fun=crt_game_1_2_1_3_Scene},
    ----------------------------------
    YX00000411001={score=0,open=true,zname="基础观察",gname="拔萝卜",nkc="",index="1",_fun=crt_game_family_1_1_Scene},
    -------------------------------------------------------------------------------------------------
    YX00000211001={score=0,open=true,zname="11-20的读写",gname="11-20的读写",nkc="",index="1",_fun=crt_NumberScene2},
    YX00000211002={score=0,open=true,zname="20以内的数数",gname="20以内的数数",nkc="",index="1",_fun=crt_game_2_1_1_2_Scene},
    YX00000211003={score=0,open=true,zname="两个两个数",gname="两个两个数",nkc="",index="1",_fun=crt_game_2_1_1_3_Scene},
    YX00000311001={score=0,open=true,zname="认识序数",gname="认识序数",nkc="",index="1",_fun=crt_game_3_1_1_1_Scene},
    YX00000311002={score=0,open=true,zname="序数的运用",gname="序数的运用",nkc="",index="1",_fun=crt_game_3_1_1_2_Scene},
    YX00000311003={score=0,open=true,zname="区分序数和基数",gname="区分序数和基数",nkc="",index="1",_fun=crt_game_3_1_1_3_Scene},

}
---------------------------------------------------------------
local _curStartId="BX000000001"--当前星球id
local _record=nil--当前进度
local _gameScore_list=nil--游戏成绩
local _curGame_id=nil--当前游戏id
wx_list=nil
function isFirst_comeIn()
    return _isFirst_come_in
end
function set_isFirst_comeIn(_bool)
    _isFirst_come_in=_bool
end
function getRecords()--获得纪录
    return _record
end
function get_classType_list()--获取星球列表
    return _record.data.classtype
end
function get_unit_list()--获得单元纪录
    return _record.data.unit
end
function get_course_list()--获得课程纪录
    table_out("课程记录",_record.data.course)
    return _record.data.course
end
--{
--                                    "id":12,
--                                    "game_id":"YX000000001",
--                                    "user_id":"54c50e0b7a7ca9e3a13472b4",
--                                    "score":3,
--                                    "create_time":"2015-01-27 11:56:59",
--                                    "unit_id":"DY000000009",
--                                    "course_id":"KC000000009",
--                                    "class_type_id":"BX000000001",
--                                    "class_id":"",
--                                    "child_name":"宝宝姓名"
--                                    }
function is_open_course(course_id)--判断课程状态
    local _list=get_course_list()
    for k,v in ipairs(_list) do
        if v.course_id==course_id then
            return true
        end
    end
    return false
end
local function open_start(_classId,_fun)--开启星球
    require "local_data"
    netWork.open_new_start(function(_state,_mes)
        if _state==200 then
            local _unit_list=local_data.get_unit_list(_classId)
            table_out("_unit_list",_unit_list)
            local _unitId=_unit_list[1].id
            netWork.open_new_unit(function(_state,_mes)
                if _state==200 then
                    local _courseId=local_data.get_course_list(_unitId)[1].id
                    netWork.open_new_kc(function (_state,_mes)
                        _fun(_state,_mes)
                    end, _courseId)
                    return
                end
                _fun(_fun(_state,_mes))
            end,_unitId)
            return
        end
        _fun(_state,_mes)
    end,_classId)
end
function complete_start(_start_id)--完成星球
    netWork.complete_new_start(function (_state,_mes)
        end,_start_id)
end
function open_course(_course_id)--开启课程
    netWork.open_new_kc(function (_state,_mes) 
    if _state==200 then
       netWork.recordsload(function(_state,_mes)
        if _state==200 then--进度读取成功
            _record=json.decode(_mes)
            table_out("record",_record)
                    local_progress.set_progress(_curStartId,_record)--设置本地记录
           end
           end)
    end
    end, _course_id)
end
function complete_course(_course_id)--完成课程
    netWork.complete_new_kc(function(_state,_mes)
        end,_course_id)
end
function open_unit(_unit_id)--开启单元
    netWork.open_new_unit(function() end,_unit_id)
end
function complete_unit(_unit_id)--完成单元
    netWork.complete_new_unit(function(_state,_mes) end,_unit_id)
end
function isOpenStar(_fun)--星球是否开启
    local _table=get_course_list()
    if #_table==0 or _table==nil then--尚未开启星球
        _isFirst_come_in=true
        open_start(_curStartId,_fun)
        return false
    end
    _fun()
    return true
end
function system_reward(_table,_fun)
    table_out("system_reward",_table)
    netWork.props_reward(_table,function (_state,_mes)
        cclog("system_reward-->")
        if _state==200 then
        end
    end)
end
function play_music_over(_course_id,_fun)--儿歌播放完成调用接口
    cclog("play_music_over-->")
    local reward={prop_id="id2",prop_type="star",prop_num=1,prop_name="star"}
    netWork.music_records_state(_course_id,function (_state,_mes)
        cclog("music_records_state-->")
        if _state==200 then--获取记录成功
            cclog("_mes------->".._mes)
            local _table=json.decode(_mes).data
            table_out("pT-->",_table)
            if _table~=nil and _table~="" and _table.reward_state==0 then
                _fun(-1,"")
                return
            end
            netWork.props_reward(reward,function (_state,_mes)
                cclog("props_reward-->")
                if _state==200 then
                    cclog("儿歌发奖成功－－－－－－－－－－－－－－－－－－－－>")
                    netWork.music_reward(_course_id,function(_state,_mes)
                        cclog("music_reward-->")
                        if _state==200 then
                            netWork.music_records(_course_id,function (_state,_mes) end)
                        end
                        _fun(_state,_mes)
                        return
                    end)
                    --                          _fun(_state,_mes)
                    return
                end
                return
            end)
            return
        else--获取记录失败
            _fun(_state,_mes)
        end
    end)
end
--function play_music_over(_course_id,_fun)--儿歌播放完成调用接口
--    local reward={prop_id="id2",prop_type="star",prop_num=1,prop_name="star"}
--    netWork.music_records_state(_course_id,function (_state,_mes)
--        if _state==200 then
--            cclog("_mes------->".._mes)
--            local _table=json.decode(_mes).data
--            table_out("pT-->",_table)
--            if _table~=nil and _table~="" and _table.reward_state==0 then
--                _fun(200,"")
--                return
--            end
--            if 1==1 then--可以发奖
--
--                netWork.props_reward(reward,function (_state,_mes)
--                    if _state==200 then
--                        cclog("儿歌发奖成功－－－－－－－－－－－－－－－－－－－－>")
--                        netWork.music_reward(_course_id,function(_state,_mes)
--                            if _state==200 then
--                                netWork.music_records(_course_id,function (_state,_mes)
--                                    end)
--                            end
--                            _fun(_state,_mes)
--                            return
--                        end)
--
--                    end
--                    _fun(_state,_mes)
--                    return
--                end)
--             return
--            end
--           return
--        end
--        _fun(_state,_mes)
--        return
--    end)
--end
function is_music_over(_course_id,_fun) -- 第一次的儿歌是否播放完
    cclog("---xxx--->".._course_id)
    netWork.music_records_state(_course_id,function (_state,_mes)
        if _state==200 then
            cclog("_mes------->".._mes)
            local _table=json.decode(_mes).data
            table_out("pT-->",_table)
            if _table~=nil and _table~="" and _table.reward_state==0 then
                cclog("_table.reward_state==0，不可领奖")
            else
                cclog("可领奖")
                _fun(200,"")
            end
        end
    end)
end
function play_mv(_name,_first,_fun)--视频播放接口
    require "myPlatform"
    myPlatform.play_mv(_name,_first,_fun)
end
local function loadRecords(_classId,_fun)--读取服务器进度
    require "netWork"
    netWork.recordsload(function(_state,_mes)
        if _state==200 then--进度读取成功
            _record=json.decode(_mes)
            table_out("record",_record)
            
            if isOpenStar(_fun)==true then--已经开启星球
                local_progress.set_progress(_classId,_record)--设置本地记录
            else
            _record=local_progress.get_progress(_classId)
            end
        else--调取本地进度记录
            require "local_progress"
            _record=local_progress.get_progress(_classId)
            _fun()
        end
    end,_classId)
end
function set_score(game_id,score,_fun)--设置游戏成绩
    cclog("set_score-->"..game_id.."score--->"..score)
    netWork.setRecords( game_id,score,function(_state,_mes)
        if _state==200 then
            local _table=json.decode(_mes).data
            local _old_score=change_scoreToStart(_table.result.last_score)
            if _old_score~=nil then
                local _num=change_scoreToStart(score)-_old_score
                if _num>0 then
                    local reward={prop_id="id2",prop_type="star",prop_num=_num,prop_name="star"}
                    netWork.props_reward(reward,function (_state,_mes)
                        if _state==200 then
                        end
                    end)
                end
            end
            table_out("score--->",_table)
            local _index= local_data.get_game_index_course_byid(game_id)
            if _index==3 then
                local _course_id=local_data.get_game_info(game_id).course_id
                complete_course(_course_id)
            end
        end
        require "local_progress"
        local_progress.set_game_score(_curStartId,game_id,score)
        _fun()
    end)
end
local function load_class_gameScore_List(_classId,_fun)--获得星球下游戏成绩
local _rGet=false
    netWork.getRecords(_classId,nil,function(_state,_mes)--获取星球下某单元成绩
        if _state==200 then
            _gameScore_list=json.decode(_mes).data
            table_out("_gameScore_list-->",_gameScore_list)
            local _local_record=local_progress.get_score(_classId).data--本地存储记录
            table_out("_local_record",_local_record)
            for k,v in ipairs(_local_record) do--补充成绩
                local _game_id=v.game_id
                local _score=v.score
            	local _isSend=true
            	for i,j in ipairs(_gameScore_list) do
            		if j.id==_game_id then
            		_isSend=false
            		end
            	end
            	if _isSend==true then
            	_rGet=true
                    cclog("_game_id--".._game_id.."--_score".._score)
                    set_score(_game_id,_score,function ()
                end)
            	end
              end--
            local_progress.set_score(_classId,json.decode(_mes))
              if _rGet==true then --再次获取成绩
              netWork.getRecords(_classId,nil,function(_state,_mes)--获取星球下某单元成绩
              if _state==200 then 
              _gameScore_list=json.decode(_mes).data
              local_progress.set_score(_classId,json.decode(_mes))
              end
                _fun(_state,_mes)
              end)
              end
              
            
    else
        require "local_progress"
        _gameScore_list=local_progress.get_score(_classId).data
        table_out("222_score-->",_gameScore_list)
--        _fun(_state,_mes)
    end
    if _rGet==false then 
    _fun(_state,_mes)
    end
    end)
end
function get_score_list()
    --    local _temp={}
    --local function isHave(_game_id,_score)
    --	for k,v in ipairs(_temp) do
    --		if v.game_id==_game_id then
    --		if v.score<_score then
    --          v.score=_score
    --		end
    --		return true
    --		end
    --	end
    ----        table.insert(_temp,{})
    --	return false
    --end
    --
    --    for k,v in ipairs(_gameScore_list) do
    --        if isHave(v.game_id,v.score)==false then
    --	   table.insert(_temp,v)
    --	   else
    --	   end
    --    end
    --    return _temp
    return _gameScore_list
end
function get_game_score(_gameId)--获取游戏成绩
    cclog("get_game_score--->_gameId--->".._gameId)
    --    if _gameId==nil then return _gameScore_list end
    table_out("_gameScore_list",_gameScore_list)
    for k,v in ipairs(_gameScore_list) do
        if v.game_id==_gameId then
            return v.score
        end
    end

    return 0
end
function change_scoreToStart(_score)
    local _num=0
    if _score==100 then
        _num=3
    elseif _score>=80 then
        _num=2
    elseif _score>=50 then
        _num=1
    end
    return _num
end
--function set_score(game_id,score,_fun)--设置游戏成绩
--    cclog("set_score-->"..game_id.."score--->"..score)
--    netWork.setRecords( game_id,score,function(_state,_mes)
--        if _state==200 then
--            local _table=json.decode(_mes).data
--            local _old_score=change_scoreToStart(_table.result.last_score)
--            if _old_score~=nil then
--                local _num=change_scoreToStart(score)-_old_score
--                if _num>0 then
--                    local reward={prop_id="id2",prop_type="star",prop_num=_num,prop_name="star"}
--                    netWork.props_reward(reward,function (_state,_mes)
--                        if _state==200 then
--                        end
--                    end)
--                end
--            end
--            table_out("score--->",_table)
--            local _index= local_data.get_game_index_course_byid(game_id)
--            if _index==3 then
--                local _course_id=local_data.get_game_info(game_id).course_id
--                complete_course(_course_id)
--            end
--        end
--        require "local_progress"
--        local_progress.set_game_score(_curStartId,game_id,score)
--        _fun()
--    end)
--end
function set_qinzi_score(game_id,score,_fun)--设置亲子游戏
    _times=_times-1
    netWork.set_qinzi_score(game_id,score,function(_state,_mes)
        if _state==200 then
        end
        _fun(_state,_mes)
    end)
end
function get_zname_bygameid(_game_id)
    cclog("---->".._game_id)
    return _gameList[_game_id].zname
end
function get_gname_bugameid(_game_id)
    return _gameList[_game_id].gname
end
function get_unit_name_bygameid(_gameId)
    return "未添加"
end
function get_course_name_bygameid(_gameId)
    return "未添加"
end
function get_game_id()
    return _curGame_id
end
function get_cur_open_game_id()--获取当前开启游戏
    local _index=1
    require "local_data"
    if _gameScore_list==nil then return _index end
    local _index=#_gameScore_list+1
    if _index>#local_data.get_game_list_by_classType(_curGameId) then return #local_data.get_game_list_by_classType(_curGameId) end
    return _index
end
function get_game_layer(_game_id)
    cclog("----!!!".._game_id)
    local _game=_gameList[_game_id]
    local  _layer=_game._fun()
    return _layer
end
function go_game(_gameId)--进入游戏

    _curGame_id=_gameId
    local function start_game(_gameId)--启动游戏
        ----------------------------------
        local function close_ani(_fun)--关屏幕
            local _spriteL=cc.Sprite:create("gameLoading/guochang_left.png")
            _spriteL:setAnchorPoint(cc.p(0,0.5))
            _spriteL:setPosition(-1000,384)
            cc.Director:getInstance():getRunningScene():addChild(_spriteL,199)
            local _spriteR=cc.Sprite:create("gameLoading/guochang_right.png")
            _spriteR:setAnchorPoint(cc.p(1,0.5))
            _spriteR:setPosition(2382,384)
            cc.Director:getInstance():getRunningScene():addChild(_spriteR,199)
            _spriteL:runAction(cc.MoveTo:create(1,cc.p(0,384)))
            _spriteR:runAction(cc.Sequence:create(cc.MoveTo:create(1,cc.p(1382,384)),cc.CallFunc:create(function()
                _fun()
            end)))
        end
        if _gameId~= "YX00000411001" then
            close_ani(function ()
                --            local  _curScene=_game._fun()
                --            _curScene:retain()
                local  _curScene=gameScene.create(_gameId)

                if cc.Director:getInstance():getRunningScene() then
                    cc.Director:getInstance():replaceScene(_curScene)
                else
                    cc.Director:getInstance():runWithScene(_curScene)
                end

                --                end
                --            _curScene:release()
            end)
        else
            local _game=_gameList[_gameId]
            local  _curScene=_game._fun()
            _curScene:retain()
            close_ani(function ()
                --            local  _curScene=_game._fun()
                --            _curScene:retain()
                --                local  _curScene=gameScene.create(_gameId)

                if cc.Director:getInstance():getRunningScene() then
                    cc.Director:getInstance():replaceScene(_curScene)
                else
                    cc.Director:getInstance():runWithScene(_curScene)
                end

                --                end
                --            _curScene:release()
            end)
        end
    end
    start_game(_gameId)
end
--function go_game(_gameId)--进入游戏
--    _curGame_id=_gameId
--    local function start_game(_gameId)--启动游戏
--        local _game=_gameList[_gameId]
--        local  _curScene=_game._fun()
--        _curScene:retain()
--        ----------------------------------
--        local function close_ani(_fun)--关屏幕
--            local _spriteL=cc.Sprite:create("gameLoading/guochang_left.png")
--            _spriteL:setAnchorPoint(cc.p(0,0.5))
--            _spriteL:setPosition(-1000,384)
--            cc.Director:getInstance():getRunningScene():addChild(_spriteL,199)
--            local _spriteR=cc.Sprite:create("gameLoading/guochang_right.png")
--            _spriteR:setAnchorPoint(cc.p(1,0.5))
--            _spriteR:setPosition(2382,384)
--            cc.Director:getInstance():getRunningScene():addChild(_spriteR,199)
--            _spriteL:runAction(cc.MoveTo:create(1,cc.p(0,384)))
--            _spriteR:runAction(cc.Sequence:create(cc.MoveTo:create(1,cc.p(1382,384)),cc.CallFunc:create(function()
--                _fun()
--            end)))
--        end
--        close_ani(function ()
--            --            local  _curScene=_game._fun()
--            --            _curScene:retain()
--            if cc.Director:getInstance():getRunningScene() then
--                cc.Director:getInstance():replaceScene(_curScene)
--            else
--                cc.Director:getInstance():runWithScene(_curScene)
--            end
--            --            _curScene:release()
--        end)
--    end
--    start_game(_gameId)
--end
local scheduler = cc.Director:getInstance():getScheduler()
local schedulerEntry=nil

_state_list={goQZ=1,goXS=2,goSS=3,goBS=4,normal=5}

function get_state()
    return _state
end
function set_state(state)
    cclog("state---->"..state)
    _state=state
end
function stop_update()
    set_state(_state_list.normal)
    if schedulerEntry~=nil then
        scheduler:unscheduleScriptEntry(schedulerEntry)
    end
end
local function get_mes_qz(competence_code,_fun)
    _competence_code=competence_code
    netWork.get_qz_list(_competence_code,function (_state,_mes)--亲子游戏列表
        if _state==200 then
            get_rank_mes(function (_state,_mes)--个人排名
                if _state==200 then
                    get_rank_list(function (_state,_mes)--排行榜
                        if _state==200 then
                            _fun(_state,_mes)
                            return
                    end
                    _fun(_state,_mes)
                    end)
                    return
            end
            _fun(_state,_mes)
            end)
            return
    end
    _fun(_state,_mes)
    end)
end
function go_xuanke_secne()
    --    require "waitLoad"
    --    waitLoad.show_net_wait()
    --    get_mes_qz(competence_code.observation,function (_state,_mes)
    --        waitLoad.dell_net_wait()
    --        goUI(_allUI.QinziXuanKeScene)
    --    end)
    require "qinzihao.QZ_main"
    local _scene=runQZ_mainScene()
    if cc.Director:getInstance():getRunningScene() then
        cc.Director:getInstance():replaceScene(_scene)
    else
        cc.Director:getInstance():runWithScene(_scene)
    end
end
function goQZStart()
    if get_state()~=_state_list.normal then return end
    goUI(_allUI.QinziXuanKeScene)
    --    go_xuanke_secne()
    --    cclog("--------->")
    --    require "waitLoad"
    --    waitLoad.show_net_wait()
    --    set_state(_state_list.goQZ)
    --
    --    require "weiNet"
    --    require "netWork"
    --    require "errmes"
    --    local _isGet=true
    --    local _imgName=client.Info.userInfo.user_id..".jpg"
    --    local function _go()
    --        waitLoad.dell_net_wait()
    --        netWork.get_wx_list(function (_state,_mes)
    --            if _state==200 then
    --                local _table=json.decode(_mes)
    --                table_out("wx_list",_table)
    --                if _table.data==nil or #_table.data==0 then--没有关注账号
    --                    waitLoad.show_wx_mes("请关注公众账号")
    --                    local function newBlend(dt)--检查是否有关注
    --                        if _isGet==false then return end
    --                        --                        waitLoad.show_net_wait()
    --                        netWork.get_wx_list(function (_state,_mes)
    --                            if _state==200 then
    --                                --                                waitLoad.dell_net_wait()
    --                                local _table=json.decode(_mes)
    --                                table_out("wx_list",_table)
    --                                wx_list=_table.data
    --                                if #_table.data>0 then--已关注
    --                                    _isGet=false
    --                                    scheduler:unscheduleScriptEntry(schedulerEntry)
    --                                    waitLoad.dell_wx_mes()
    --                                    --                                    goUI(_allUI.QinziXuanKeScene)
    --                                    go_xuanke_secne()
    --                                end
    --                            end
    --                        end)
    --                    end
    --                    schedulerEntry = scheduler:scheduleScriptFunc(newBlend, 1.0, false)
    --                    return
    --                end
    --                --                goUI(_allUI.QinziXuanKeScene)
    --                go_xuanke_secne()
    --            end
    --        end)
    --    end
    --    local _ishaveImg=mFile:isHave(_imgName)
    --    if _ishaveImg==false then --请求微信图片
    --        cclog("---------------没有图片")
    --        weiNet.get_wx_image(function (_state,_mes)
    --            if _state==200 then
    --                _go()
    --                return
    --            end
    --        end)
    --        return
    --    end
    --    _go()
end
function Placement(_class_id,_fun)--分班
--    _fun(nil,nil)
--netWork.Placement(_class_id,function(_state,_mes)
--        _fun(nil,nil)
--end)

end
local function _to_start(_classId,_fun)
    require "waitLoad"
    waitLoad.show_net_wait()
    load_class_gameScore_List(_classId,function (_state,_mes)
        set_state(_state_list.normal)
        if _state==200 then--获取成绩成功
            loadRecords(_classId,_fun)
            return
        else
            cclog("_classId---->".._classId)
            _record=local_progress.get_progress(_classId)
            table_out("_record_out",_record)
            _fun()
            cclog("网络请求失败")
        end
        waitLoad.dell_net_wait()
    end)
end
--local function _to_start(_classId,_fun)
--    require "waitLoad"
--    waitLoad.show_net_wait()
--    load_class_gameScore_List(_classId,function (_state,_mes)
--        set_state(_state_list.normal)
--        if _state==200 then--获取成绩成功
--            loadRecords(_classId,_fun)
--            return
--        else
--            cclog("_classId---->".._classId)
--            _record=local_progress.get_progress(_classId)
--            table_out("_record_out",_record)
--            _fun()
--            cclog("网络请求失败")
--        end
--        waitLoad.dell_net_wait()
--    end)
--end
local _class_info=false
function get_class_info(_class_id,_fun)--获取用户班级信s

    if _class_info==true then return end
    _class_info=true
    local function _callBack(_state,_mes)--回调函数
        _class_info=false
        _fun(_state,_mes)
    end
    local _id
    netWork.getPlacementInfo(_class_id,function(_state,_mes)
        if _state==200 then
            local _table=json.decode(_mes).data
            table_out("class-info",_table)
            if _table==nil or _table==""then--无分班信息
                netWork.Placement(_class_id,function(_state,_mes)

                        if _state==200 then--分班成功
                            _id=scheduler:scheduleScriptFunc(function(dt)
                                netWork.getPlacementInfo(_class_id,function(_state,_mes)
                                    if _state==200 then
                                        --                                _class_info=false
                                        _callBack(_state,_mes)
                                        if _id~=nil then
                                            scheduler:unscheduleScriptEntry(_id)
                                        end
                                        return
                                    end
                                    --                                _class_info=false
                                    _callBack(_state,_mes)
                                end)
                            end, 1.0, false)
                        return
                        end
                        --                    _class_info=false
                        _callBack(_state,_mes)
                end)
            return
            end
            --            _class_info=false
            _callBack(_state,_mes)
            return
        end
        --        _class_info=false
        _callBack(_state,_mes)
    end)
end
function goStart(_classId,_fun)--进入星球设置编号
    get_class_info(_classId,function (_state,_mes)
        if _state==200 then
        end
    end)
require "local_progress"
if get_state()~=_state_list.normal then return end
set_state(_state_list.goQZ)
_curStartId=_classId
_to_start(_classId,_fun)
--    require "local_progress"
--    if get_state()~=_state_list.normal then return end
--    set_state(_state_list.goQZ)
--    _curStartId=_classId
--    _to_start(_classId,_fun)

end
function getCurSatrt()--获得当前所在星球编号
    return _curStartId
end
function getCurSatrt_index()--获得当前所在星球编号
    local _class_id=getCurSatrt()
    require "local_data"
    local _table=local_data.get_classList().data
    table_out("classList",_table)
    for k,v in ipairs(_table) do
        if v.id==_class_id then
            cclog("id==="..v.id.."-->index--->"..k)
            return k
        end
    end
    return nil
end
function check_time(_game_id,_fun)
    netWork.get_challengetimes(_game_id,function(_state,_mes)
        if _state ==200 then
            local _table=json.decode(_mes).data
            local _time=_table.challenge_times
            _times=3-_time
            _fun(_times)
            return
        end
        --        _times=3
        _fun(_times)
    end)
end
function get_match_list(_fun)
    netWork.get_match(_competence_code,function(_state,_mes)
        if _state==200 then
        end
        _fun(_state,_mes)
    end)
end
local function get_wxInfo(_open_id,_fun)
    require "weiNet"
    weiNet.get_wx_info(_open_id,function (_state,_mes)
        if _state==200 then
            --		get_icon_Image
            _fun(_state,_mes)
        end
    end)
end
function get_info_total(_user_id,_fun)--获得用户信息
    local _table={_name="",pet_id="",area=""}
    netWork.getUserInfo(function(_state,_mes)
        if _state==200 then--获取用户信息成功
            local _t=json.decode(_mes).data
            table_out("user_info",_t)
            _table.pet_id=_t.pet_info.pet_id
            _table.area=_t.area
            _table._name=_t.name
            _fun(_state,_table)
            return
        end
    end,_user_id)
end

function get_game_rank(_game_id,_fun)
    netWork.get_game_rank(_game_id,function(_state,_mes)
        _fun(_state,_mes)
    end)
end
function get_reward_complete(_course_id,_fun)
    cclog("id---->".._course_id)
    netWork.get_reward_complete(_course_id,_fun)
end
